import mysql.connector
import pandas as pd
mydb = mysql.connector.connect(
host="localhost",
port="3317",
user="root",
password="Cancer159x",
)
cursor = mydb.cursor()
cursor.execute('USE alc')
df = pd.read_sql('SELECT * FROM alc', con=mydb)
df
country | alcconsumption | incomeperperson | suicideper100th | employrate | urbanrate | |
---|---|---|---|---|---|---|
0 | Afghanistan | 0.03 | 6.684385 | 55.70000076 | 24.04 | |
1 | Albania | 7.29 | 1914.996551 | 7.699330 | 51.40000153 | 46.72 |
2 | Algeria | 0.69 | 2231.993335 | 4.848770 | 50.5 | 65.22 |
3 | Andorra | 10.17 | 21943.3399 | 5.362179 | 88.92 | |
4 | Angola | 5.57 | 1381.004268 | 14.554677 | 75.69999695 | 56.70 |
... | ... | ... | ... | ... | ... | ... |
176 | Venezuela | 7.60 | 5528.363114 | 4.119620 | 59.90000153 | 93.32 |
177 | Vietnam | 3.91 | 722.8075588 | 11.653322 | 71 | 27.84 |
178 | Yemen, Rep. | 0.20 | 610.3573673 | 6.265789 | 39 | 30.64 |
179 | Zambia | 3.56 | 432.226337 | 12.019036 | 61 | 35.42 |
180 | Zimbabwe | 4.96 | 320.7718899 | 13.905267 | 66.80000305 | 37.34 |
181 rows × 6 columns
import numpy as np
import pandas as pd
import scipy.stats as stats
import seaborn as sns
from statistics import mean
import matplotlib.pyplot as plt
from matplotlib.pyplot import figure
df = df.sort_values(by='alcconsumption', ascending=False)
df.head(5)
country | alcconsumption | incomeperperson | suicideper100th | employrate | urbanrate | |
---|---|---|---|---|---|---|
108 | Moldova | 23.01 | 595.8745345 | 15.53849 | 44.29999924 | 41.76 |
87 | Korea, Rep. | 19.15 | 16372.49978 | 22.40456 | 58.90000153 | 81.46 |
15 | Belarus | 18.85 | 2737.670379 | 26.87469 | 53.40000153 | 73.46 |
169 | Ukraine | 17.47 | 1036.830725 | 18.95457 | 54.40000153 | 67.98 |
55 | Estonia | 17.24 | 6238.537506 | 16.95924 | 56.5 | 69.46 |
df.iloc[7,:]
country Lithuania alcconsumption 16.3 incomeperperson 5332.238591 suicideper100th 33.34186 employrate 53.09999847 urbanrate 66.96 Name: 96, dtype: object
Lietuva nėra daugiausiai alkoholio suvartojanti šalis, bet pasaulio sąraše užima 8 vietą, kas nėra gerai.
df = df.sort_values(by='incomeperperson', ascending=True)
df.iloc[5: 10]
country | alcconsumption | incomeperperson | suicideper100th | employrate | urbanrate | |
---|---|---|---|---|---|---|
38 | Congo, Dem. Rep. | 3.39 | 103.7758572 | 14.713020 | 66.19999695 | 33.96 |
169 | Ukraine | 17.47 | 1036.830725 | 18.954570 | 54.40000153 | 67.98 |
164 | Trinidad and Tobago | 6.16 | 10480.8172 | 14.547167 | 61.5 | 13.22 |
6 | Argentina | 9.35 | 10749.41924 | 7.765584 | 58.40000153 | 92.00 |
103 | Malta | 4.10 | 11066.78414 | 4.551121 | 46.79999924 | 94.26 |
Uždarbis neturi įtakos alkoholio suvartojimui, Ukrainoje galima matyti, kad uždarbis mažas bet alkoholio suvartojimas labai didelis.
df = df.sort_values(by='suicideper100th', ascending=False)
df.head(10)
country | alcconsumption | incomeperperson | suicideper100th | employrate | urbanrate | |
---|---|---|---|---|---|---|
70 | Guyana | 8.70 | 1200.652075 | 35.752872 | 58.90000153 | 28.38 |
96 | Lithuania | 16.30 | 5332.238591 | 33.341860 | 53.09999847 | 66.96 |
148 | Somalia | 0.50 | 29.864164 | 66 | 36.52 | |
151 | Sri Lanka | 0.81 | 1295.742686 | 28.104046 | 55.09999847 | 15.10 |
133 | Russia | 16.23 | 2923.144355 | 27.874160 | 58.79999924 | 72.84 |
15 | Belarus | 18.85 | 2737.670379 | 26.874690 | 53.40000153 | 73.46 |
90 | Laos | 6.99 | 554.8798401 | 26.219198 | 78.19999695 | 30.88 |
85 | Kazakhstan | 11.10 | 2481.718918 | 25.404600 | 63.70000076 | 57.94 |
87 | Korea, Rep. | 19.15 | 16372.49978 | 22.404560 | 58.90000153 | 81.46 |
153 | Suriname | 6.56 | 2668.020519 | 20.747431 | 44.70000076 | 74.92 |
Asmenys gyvenantys šalyse, kuriose geria daug, yra linkę ir į savižudybes.
df.sort_values(by=['alcconsumption', 'employrate'])
country | alcconsumption | incomeperperson | suicideper100th | employrate | urbanrate | |
---|---|---|---|---|---|---|
0 | Afghanistan | 0.03 | 6.684385 | 55.70000076 | 24.04 | |
122 | Pakistan | 0.05 | 668.547943 | 12.869815 | 51 | 36.16 |
95 | Libya | 0.10 | 7885.468037 | 4.667025 | 48.59999847 | 77.54 |
88 | Kuwait | 0.10 | 1.498057 | 65.69999695 | 98.36 | |
104 | Mauritania | 0.11 | 609.1312059 | 6.882952 | 46.90000153 | 41.00 |
... | ... | ... | ... | ... | ... | ... |
55 | Estonia | 17.24 | 6238.537506 | 16.959240 | 56.5 | 69.46 |
169 | Ukraine | 17.47 | 1036.830725 | 18.954570 | 54.40000153 | 67.98 |
15 | Belarus | 18.85 | 2737.670379 | 26.874690 | 53.40000153 | 73.46 |
87 | Korea, Rep. | 19.15 | 16372.49978 | 22.404560 | 58.90000153 | 81.46 |
108 | Moldova | 23.01 | 595.8745345 | 15.538490 | 44.29999924 | 41.76 |
181 rows × 6 columns
Ne, šalyse, kuriose daug išgeriama yra ir nemažas darbingumo lygis.
df = df.sort_values(["urbanrate", "alcconsumption"], ascending = (False, False))
df.head(10)
country | alcconsumption | incomeperperson | suicideper100th | employrate | urbanrate | |
---|---|---|---|---|---|---|
144 | Singapore | 1.54 | 32535.83251 | 9.127511 | 62.40000153 | 100.00 |
88 | Kuwait | 0.10 | 1.498057 | 65.69999695 | 98.36 | |
16 | Belgium | 10.41 | 24496.04826 | 15.953850 | 48.59999847 | 97.36 |
131 | Qatar | 1.29 | 33931.83208 | 2.515721 | 76 | 95.64 |
103 | Malta | 4.10 | 11066.78414 | 4.551121 | 46.79999924 | 94.26 |
176 | Venezuela | 7.60 | 5528.363114 | 4.119620 | 59.90000153 | 93.32 |
173 | Uruguay | 8.99 | 9106.327234 | 14.537270 | 57.5 | 92.30 |
74 | Iceland | 7.38 | 33945.31442 | 11.426181 | 73.59999847 | 92.26 |
6 | Argentina | 9.35 | 10749.41924 | 7.765584 | 58.40000153 | 92.00 |
80 | Israel | 2.52 | 22275.75166 | 5.931845 | 51.29999924 | 91.66 |
Teigiamai, plėtra mažina suvartojamo alkoholio kiekį.
df[df.alcconsumption > 10.99]
country | alcconsumption | incomeperperson | suicideper100th | employrate | urbanrate | |
---|---|---|---|---|---|---|
108 | Moldova | 23.01 | 595.8745345 | 15.538490 | 44.29999924 | 41.76 |
87 | Korea, Rep. | 19.15 | 16372.49978 | 22.404560 | 58.90000153 | 81.46 |
15 | Belarus | 18.85 | 2737.670379 | 26.874690 | 53.40000153 | 73.46 |
169 | Ukraine | 17.47 | 1036.830725 | 18.954570 | 54.40000153 | 67.98 |
55 | Estonia | 17.24 | 6238.537506 | 16.959240 | 56.5 | 69.46 |
45 | Czech Rep. | 16.47 | 7381.312751 | 12.367980 | 56 | 73.50 |
168 | Uganda | 16.40 | 377.4211133 | 12.289122 | 83.19999695 | 12.98 |
96 | Lithuania | 16.30 | 5332.238591 | 33.341860 | 53.09999847 | 66.96 |
133 | Russia | 16.23 | 2923.144355 | 27.874160 | 58.79999924 | 72.84 |
132 | Romania | 16.15 | 2636.7878 | 10.059320 | 49.5 | 54.24 |
73 | Hungary | 16.12 | 5634.003948 | 20.162010 | 47.29999924 | 67.50 |
42 | Croatia | 15.00 | 6338.494668 | 14.776250 | 47.09999847 | 57.28 |
146 | Slovenia | 14.94 | 12729.4544 | 19.422610 | 55.90000153 | 48.60 |
79 | Ireland | 14.92 | 27595.09135 | 10.365070 | 59.90000153 | 61.34 |
129 | Poland | 14.43 | 6575.745044 | 13.637060 | 48.70000076 | 61.32 |
130 | Portugal | 13.89 | 11744.83417 | 8.188375 | 57.59999847 | 59.46 |
7 | Armenia | 13.66 | 1326.741757 | 3.741588 | 40.09999847 | 63.86 |
91 | Latvia | 13.45 | 5011.219456 | 20.369590 | 56.79999924 | 68.12 |
10 | Azerbaijan | 13.34 | 2344.896916 | 1.380965 | 60.90000153 | 51.92 |
145 | Slovak Republic | 13.31 | 8445.526689 | 10.645740 | 53.40000153 | 56.56 |
171 | United Kingdom | 13.24 | 28033.48928 | 6.014659 | 59.29999924 | 89.94 |
58 | Finland | 13.10 | 27110.73159 | 16.234370 | 57.20000076 | 63.30 |
97 | Luxembourg | 12.84 | 52301.58718 | 12.405918 | 53.5 | 82.44 |
119 | Nigeria | 12.72 | 544.5994767 | 7.631050 | 50.90000153 | 48.36 |
59 | France | 12.48 | 22878.46657 | 14.091530 | 51.20000076 | 77.36 |
9 | Austria | 12.40 | 26692.98411 | 13.094370 | 57.09999847 | 67.16 |
141 | Serbia | 12.21 | 1194.711433 | 13.716340 | 52.04 | |
63 | Germany | 12.14 | 25306.18719 | 9.211085 | 53.5 | 73.64 |
142 | Seychelles | 12.11 | 8614.120219 | 9.507928 | 54.34 | |
113 | Namibia | 12.09 | 2667.24671 | 8.021970 | 42 | 36.84 |
135 | Saint Lucia | 12.05 | 5248.582321 | 8.210948 | 27.84 | |
46 | Denmark | 12.02 | 30532.27704 | 8.973104 | 63.09999847 | 86.68 |
150 | Spain | 11.83 | 15461.75837 | 5.888479 | 52.5 | 77.12 |
156 | Switzerland | 11.41 | 37662.75125 | 13.239810 | 64.30000305 | 73.48 |
25 | Bulgaria | 11.40 | 2549.558474 | 9.216544 | 47.29999924 | 71.10 |
85 | Kazakhstan | 11.10 | 2481.718918 | 25.404600 | 63.70000076 | 57.94 |
65 | Greece | 11.01 | 13577.87989 | 2.816705 | 49.59999847 | 61.00 |
df["alcconsumption"].mean()
6.7333149171270685
countries = ['Lithuania', 'Russia', 'Ukraine']
slices = [16.3, 16.23, 17.47]
color = ['g', 'r', 'b']
plt.pie(slices, labels=countries, colors=color, shadow=True, startangle=90, autopct='%1.2f%%')
plt.legend()
plt.show()
Išvados būtų tokios
Pasaulyje, kas metus yra išgeriama vos ne 7 litrai alkoholio per metus, kas nėra mažai, šie skaičiai kas metus didėja ir tai nėra į naudą.
Lietuva patenka i top 10 sarašą pagal suvartojamą alkoholį, ne itin garbinga vieta būti tokiame saraše.
Geriantys žmonės labiau linkę į savižudybes, bet kaip bebūtų keista, darbingumui tai netrugdo.
Tiek Ukraina, Tiek Lietuva, uždirba itin mažai, bet išgeria itin daug.
Žinome, kad alkoholis naikina smegenų lasteles, tokiu gėrimo mąstu pradės mažėti darbingumas, bus daugiau smurto šeimose, taigi kalbant apie alkoholį viskas eina į ne kokią pusę.</font>